<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>退税单管理</title>
    <s:head/>
</head>
<script type="text/javascript">
    var formSetting = {
        title: "退税单管理",
        module: 'query',
        columns: [{
            name: "state",
            label: "退税单状态",
            type: "dropdown",
            dropdownType: "ajax",
            url: "../base/dropdown-taxState",
            op: "eq",
            minLength: 0
        },
            {
                name: "ctime",
                label: "放行时间 从",
                type: "date"
            },
            {
                name: "ctime",
                label: "到",
                type: "date"
            }
        ],
        buttons: {
            custom: [
                {
                    id: "updatebtn0",
                    value: "标识为已退回",
                    click: function () {
                        var id = $("#taxInformsDataGrid").jqGrid("getGridParam",
                                "selrow");
                        if (id) {
                            var ret = $("#taxInformsDataGrid").jqGrid('getRowData', id);
                            var iddata = "id=" + $(ret).attr("taxInform.id");

                            $.ajax({
                                url: "taxInform-validateCheckBackTax",
                                cache: false,
                                dataType: "json",
                                data: iddata,
                                success: function (data) {
                                    if ($.parseJSON(data.msg).state == "1") {
                                        jw.confirm("确定要将该业务标识为已退回?", function () {
                                                    $.ajax({
                                                        url: "taxInform-validateBackTax",
                                                        cache: false,
                                                        dataType: "json",
                                                        data: iddata,
                                                        success: function (data) {
                                                            jw.alert($.parseJSON(data.msg).msg);
                                                            $("#taxInformsDataGrid").jqGrid("setGridParam",
                                                                    {
                                                                        search: true
                                                                        // 将jqGrid的search选项设为true
                                                                    }).trigger("reloadGrid", [{
                                                                page: 1
                                                            }]);
                                                        }
                                                    });
                                                },
                                                function () {
                                                    return;
                                                });
                                    }
                                    else {
                                        jw.alert("只有未退回的单才能标识为已退回");
                                    }
                                }
                            });
                        } else {
                            jw.alert("请点击需要操作的数据!");
                        }
                    }
                },
                {
                    id: "updatebtn1",
                    value: "标识为已结退",
                    click: function () {
                        var id = $("#taxInformsDataGrid").jqGrid("getGridParam",
                                "selrow");
                        if (id) {
                            var ret = $("#taxInformsDataGrid").jqGrid('getRowData', id);
                            var data = "id=" + $(ret).attr("taxInform.id");
                            jw.confirm("确定要将该业务标识为已结退?", function () {
                                        $.ajax({
                                            url: "taxInform-validateReturnTax",
                                            cache: false,
                                            dataType: "json",
                                            data: data,
                                            success: function (data) {
                                                jw.alert($.parseJSON(data.msg).msg);
                                                $("#taxInformsDataGrid").jqGrid("setGridParam",
                                                        {
                                                            search: true
                                                            // 将jqGrid的search选项设为true
                                                        }).trigger("reloadGrid", [{
                                                    page: 1
                                                }]);
                                            }
                                        });
                                    },
                                    function () {
                                        return;
                                    });
                        } else {
                            jw.alert("请点击需要操作的数据!");
                        }
                    }
                }
            ]
        },
        grid: {
            id: "taxInformsDataGrid",
            title: "查询结果",
            url: "taxInform-findListForSup",
            /* postData : {
             "pid" : pid
             }, */
            colModel: [{
                index: "id",
                name: "taxInform.id",
                hidden: true
            }, {
                index: "busiId",
                name: "businessDto.busiId",
                label: "业务编号",
                sortable: false
            }, {
                index: "customerName",
                name: "businessDto.customerName",
                label: "真实托运方公司",
                sortable: false
            }, {
                index: "ctime",
                name: "businessDto.ctime",
                label: "业务时间",
                formatter: 'date',
                formatoptions: {srcformat: 'Y-m-d H:i:s', newformat: 'Y-m-d H:i:s'},
                sortable: false
            }, {
                index: "taxBpk",
                name: "taxInform.taxBpk",
                label: "报关单号",
                sortable: false
            }, {
                index: "RELEASE_DATE",
                name: "taxInform.releaseDate",
                label: "放行时间",
                formatter: 'date',
                formatoptions: {srcformat: 'Y-m-d H:i:s', newformat: 'Y-m-d H:i:s'}
            }, {
                index: "deadLineDate",
                name: "deadLineDate",
                label: "退税截止时间",
                formatter: 'date',
                formatoptions: {srcformat: 'Y-m-d H:i:s', newformat: 'Y-m-d H:i:s'},
                sortable: false
            }, {
                index: "alertState",
                name: "taxInform.alertState",
                hidden: true
            }, {
                index: "taxState",
                name: "taxInform.state",
                hidden: true
            }, {
                index: "STATE",
                name: "stateString",
                label: "退税单状态"
            }, {
                index: "RETURN_DATE",
                name: "taxInform.returnDate",
                label: "退单时间",
                formatter: 'date',
                formatoptions: {srcformat: 'Y-m-d H:i:s', newformat: 'Y-m-d H:i:s'}
            }, {
                index: "supRemark",
                name: "taxInform.supRemark",
                label: "备注",
                sortable: false
            }],
            jsonReader: {
                userdata: "msg",
                root: "taxInformDTOs"
            },
            gridComplete: function () {
                var msg = $("#taxInformsDataGrid").jqGrid('getGridParam', 'userData');
                if (typeof msg == "string") {
                    jw.alert(msg);
                }
            },
            loadComplete: function (data) {
                var ids = $("#taxInformsDataGrid").getDataIDs();
                for (var i = 0; i < ids.length; i++) {
                    var arrayData = $("#taxInformsDataGrid").getRowData(ids[i]);
                    if ($(arrayData).attr('taxInform.alertState') == "1") {
                        //if(arrayData.alertState=="1") {
                        $($("#" + (i + 1)).find("td")[9]).addClass("biz_state_alert");
                    }
                    else if ($(arrayData).attr('taxInform.state') == "TAXS3") {
                        //$($("#"+(i+1)).find("td")[9]).addClass("biz_state_finish");
                    }
                }
            }
        }
    };
    $(document).ready(function () {
        $("#taxInformDataTable").mrdForm(formSetting);
    });
    //点击显示详细信息
    function showState(trId, symbol, busiId, type) {
        $.post(
                "taxInform-findState",
                {busiId: busiId, type: type},
                function (data) {
                    var s = data.state;
                    if (!s) {
                        s = "没有相关业务信息";
                    }
                    $("#taxInformsDataGrid").setCell(trId, symbol, s);
                }
        );
    }
</script>
</head>
<body>
<div id="taxInformDataTable"></div>
</body>
</html>
